#include <stdio.h>
#include <string.h>

int n;
int field[10][10] = {0};

struct pos
{
    int x, y;
};

enum dir
{
    up = 0,
    down = 1,
    left = 2,
    right = 3,
    done = -1,
} curdir = down;

void mov(enum dir *d, struct pos *p)
{
    if (field[p->y - 1][p->x] &&
        field[p->y + 1][p->x] &&
        field[p->y][p->x - 1] &&
        field[p->y][p->x + 1])
    {
        *d = done;
    }
    switch (*d)
    {
    case up:
    U:
        if (p->y > 1 && field[p->y - 1][p->x] == 0)
        {
            p->y -= 1;
        }
        else
        {
            *d = right;
            goto R;
        }
        break;
    case down:
    D:
        if (p->y < n && field[p->y + 1][p->x] == 0)
        {
            p->y += 1;
        }
        else
        {
            *d = left;
            goto L;
        }
        break;
    case left:
    L:
        if (p->x > 1 && field[p->y][p->x - 1] == 0)
        {
            p->x -= 1;
        }
        else
        {
            *d = up;
            goto U;
        }
        break;
    case right:
    R:
        if (p->x < n && field[p->y][p->x + 1] == 0)
        {
            p->x += 1;
        }
        else
        {
            *d = down;
            goto D;
        }
        break;
    case done:
    X:
        return;

    default:
        break;
    }
}

int main()
{
    scanf("%i", &n);
    struct pos curpos = {.x = n, .y = 1};
    int k = 1;
    while (curdir != done)
    {
        field[curpos.y][curpos.x] = k++;
        mov(&curdir, &curpos);
    }
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            printf(" %3i" + (j == 1), field[i][j]);
        }
        printf("\n");
    }
    return 0;
}